<?php
/**
 * Created by PhpStorm.
 * User: deng
 * Date: 2015/3/6
 * Time: 23:29
 */

namespace Serve\Controller;

use Common\Controller\NormalApiController;
use Think\Controller;

vendor("Qiniu.rs");
vendor("Qiniu.auth_digest");

class QiniuController extends NormalApiController
{
    public function uptoken()
    {
        if ($this->_method == 'options') {
            $this->options('Access-Control-Allow-Methods:GET,OPTIONS');
        }
        $bucket = 'metalab';
        $accessKey = '_ATGryARBwpe-DEONUbpzef-OkKQXhWXulwgbp2V';
        $secretKey = 'nqV7A8pTd4ov7RpryIpxZJ_K2AFMfF4QHyXSkrZg';
        Qiniu_SetKeys($accessKey, $secretKey);
        $putPolicy = new \Qiniu_RS_PutPolicy($bucket);
        $upToken = $putPolicy->Token(null);
        $result['uptoken'] = $upToken;
        Success(200, $result);
    }
}